<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/conn.asp"-->
<!--#include file="lib/saferequest.asp"-->

<!DOCTYPE html> 
<html> 
<head> 
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
<title></title> 
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&language=zh-CN"></script> 
<script type="text/javascript" src="lib/jquery_lastest.js"></script>
<script type="text/javascript"> 
	$(function() {
 
		var map;
		var myLatlng;
		var	geocoder;
		var marker;
		var infowindow;
		geocoder = new google.maps.Geocoder();
		marker=new google.maps.Marker();
		infowindow = new google.maps.InfoWindow();
		//地图初始化
		myLatlng = new google.maps.LatLng(29.868336, 121.54399);
		var mapOptions = {
			zoom: 6,                //缩放级别
			center: myLatlng,       //将地图的中心设置为指定的地理点 可以使用 0（最低缩放级别，在地图上可以看到整个世界）到 19（最高缩放级别，可以看到独立建筑物）之间的缩放级别
			mapTypeId: google.maps.MapTypeId.ROADMAP,   //ROADMAP-默认视图 SATELLITE-显示Google地球卫星图像 HYBRID-混合显示普通视图和卫星视图 TERRAIN-地形图
			mapTypeControl: true,
			mapTypeControlOptions: {
				style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
			},
			navigationControl: true,
			navigationControlOptions: {
				style: google.maps.NavigationControlStyle.SMALL,
				position: google.maps.ControlPosition.LEFT
			},
			scaleControl: true,    //比例尺
			scaleControlOptions: {
				position: google.maps.ControlPosition.BOTTOM_LEFT
			}
		};
		map = new google.maps.Map(document.getElementById("map_canvas"),mapOptions);//编写 JavaScript 函数创建“map”对象
		function codeAddress() {
			var address = $("#customer_address").val();
			if (geocoder) {
			 geocoder.geocode( { 'address': address}, function(results, status) {
					if (status == google.maps.GeocoderStatus.OK) {	
					$("#lat").val(results[0].geometry.location.lat());
					$("#lng").val(results[0].geometry.location.lng());
					map.setZoom(16);
					
						map.setCenter(results[0].geometry.location);
						marker.setOptions({
								map: map,
								position: results[0].geometry.location,
								title:$("#customer_name").val()
						});
						var contentString = '<div id="content">'+
							'<h1 id="firstHeading">'+$("#customer_name").val()+'</h1>'+
							'<div id="bodyContent">'+
							'<p>地址：' +$("#customer_address").val()+'</p>'+
							'<p>联系人：' +$("#customer_owner").val()+'</p>'+
							'<p>联系电话：' +$("#customer_phone").val()+'</p>'+
							'<p>注意事项：' +$("#customer_memo").val()+'</p>'+
							'</div>'+
							'</div>';

						infowindow.setOptions({
								content: contentString
						});

						google.maps.event.addListener(marker, 'click', function() {
							infowindow.open(map,marker);
						});
					} else {
						alert("地图上未找到当前地址: " + status);
						$("#lat").val("");
						$("#lng").val("");
					}
				});
			}
		}
		myLatlng = new google.maps.LatLng($("#lat").val(), $("#lng").val());
		map.setZoom(13);
		map.setCenter(myLatlng);
		marker.setOptions({
				map: map,
				position: myLatlng
		});

		
		
		
	});
</script> 
</head> 
<body>
<%
	sTable=saferequest("show_table",0)
	iID=saferequest("show_id",1)
	sql="select * from "&sTable&" where "&sTable&"_id="&iID
	'response.write sql
	'response.end
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,1,1
	if not rs.eof then
		do while not rs.eof
%>
	<input id="lat" type="hidden" value="<%=rs("customer_address_lat")%>" />
	<input id="lng" type="hidden" value="<%=rs("customer_address_lng")%>" />
<%
			rs.movenext
		loop
	end if
	
	rs.close
	set rs=nothing
	conn.close
	set conn=nothing
%>
  <div id="map_canvas" style="width: 100%; height: 320px"></div> 
</body> 
</html> 